﻿using System;
using System.Text;
using System.Data;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Skyworth.CRM.Common;
using Skyworth.CRM.Service.IBLL;
using Skyworth.CRM.Service.Entity;

namespace Skyworth.CRM.Web.CustomerManagement
{
    public partial class SalesLeadsDetail : System.Web.UI.Page
    {
        protected int leadId = 0;
        private static ICustActivitiesBLL actBll = IocContainer.Instance.Resolve<ICustActivitiesBLL>();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int.TryParse(Request.QueryString["LeadId"], out leadId);
                DataTable dtAct = actBll.Query(string.Format(" and tca.FBusinessoppId={0}", leadId));
                this.actDetailBody.Text = BuildDetail(dtAct);
            }
        }

        protected string BuildDetail(DataTable dt)
        {
            StringBuilder result = new StringBuilder();
            if (dt != null && dt.Rows.Count > 0)
            {
                foreach (DataRow dataRow in dt.Rows)
                {
                    result.AppendFormat("<tr rel='{0}'>", dataRow["FItemId"]);
                    result.AppendFormat("<td>{0}</td><td>{1}</td><td>{2}</td>", dataRow["FNumber"], dataRow["BssCode"], dataRow["FType"]);
                    result.AppendFormat("<td>{0}</td><td>{1}</td><td>{2}</td>", dataRow["FOppDate"], dataRow["FNote"], dataRow["EmpName"]);
                    result.AppendFormat("<td>{0}</td><td>{1}</td>", dataRow["FDate"], dataRow["FSubmitDate"]);
                    result.Append("</tr>");
                }
            }
            return result.ToString();
        }
    }
}